package com.art.sunflower.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface StudentMapper {

    @Select("select * from classroom_and_student_view")
    List<Map<String, Object>> selectList();

    @Insert("insert into student(user_id, sex, enter_year, parent_name, classroom_id) values(#{id}, #{sex}, #{year}, #{parentName}, #{classroomId})")
    void insertStudent(Integer id, String sex, Integer year, String parentName, Integer classroomId);

    @Update("update student set sex = #{sex}, enter_year = #{year}, parent_name = #{name}, classroom_id = #{clsId} where id = #{id}")
    void updateStudent(Integer id, String sex, Integer year, String name, Integer clsId);

    @Select("select * from student where id = #{id}")
    Map<String, Object> selectStudent(Integer id);

    @Delete("delete from student where id = #{id}")
    void delete(Integer id);

    @Select("select * from classroom_and_student_view where id = #{id}")
    Map<String, Object> selectById(Integer id);

    @Select("select studentId from teacher_classroom_student_view where userId = #{userId}")
    List<Integer> selectTeacherClassroomStudent(Integer userId);

    @Select("select studentId from teacher_classes_student_view where userId = #{userId}")
    List<Integer> selectTeacherClassesStudent(Integer userId);

}
